home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14112 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1010 b 

  1. Path: en.com!usenet
  2. From: dpsm@en.com (Dale P. Smith)
  3. Newsgroups: comp.lang.c++
  4. Subject: stl newbie help
  5. Date: Thu, 28 Mar 1996 19:34:30 GMT
  6. Organization: RheoActive
  7. Message-ID: <315ae9a1.455438@news.en.com>
  8. NNTP-Posting-Host: p8-ts4.en.net
  9. X-Newsreader: Forte Agent .99d/16.182
  10.  
  11. Help!
  12.  
  13. I am attempting to understand/use the stl, an while I have dabbled
  14. in C++ since about 1987, I am not experienced in templates and other
  15. new features.
  16.  
  17. Ok, say you have a map. the key is an int and the data is a string.
  18.    map<int, String, less<int>> Table;
  19.  
  20. I can do:
  21.     Table[3] = "foo be doo";
  22.  
  23. What I want to understand how to do is declare a function class that
  24. can be used with something like for_each:
  25.     for_each(Table.begin(), Table.end(), FunctionClassForEachThing);
  26.  
  27. I know that I have to create a class that has operator() in it. What
  28. should this thing look like?  I can't find (or can't see) any examples
  29. in the stl documentation.
  30.  
  31. Thanks!
  32.  
  33. Dale
  34.  
  35. Dale P. Smith
  36. dpsm@en.com        home
  37. dpsm@lubrizol.com  work
  38.